<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/5/23
  Time: 16:56
  To change this template use File | Settings | File Templates.
--%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" +
			request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
	<meta charset="UTF-8">
	<title>安全设置</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<link rel="shortcut icon" href="<%=basePath%>static/favicon.ico" type="image/x-icon"/>
	<link rel="stylesheet" href="<%=basePath%>static/css/font.css">
	<link rel="stylesheet" href="<%=basePath%>static/css/xadmin.css">
	<link rel="stylesheet" href="<%=basePath%>static/css/bootstrap.css">
	<script type="text/javascript" src="<%=basePath%>static/js/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>static/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>static/js/jqPaginator.js"></script>
	<script type="text/javascript" src="<%=basePath%>static/lib/layui/layui.js" charset="utf-8"></script>
	<script type="text/javascript" src="<%=basePath%>static/js/xadmin.js"></script>
</head>
<body>
<table class="layui-table">
	<thead>
	<tr>
		<th>序号</th>
		<th>账号</th>
		<th>密码</th>
		<th>姓名</th>
		<th>爱好</th>
		<th>电话</th>
		<th>权限</th>
		<th>操作</th>
	</tr>
	</thead>
	<tbody id="tab"></tbody>
</table>

<script>
    $(document).ready(function () {
        $.ajax({
            url:"<%=basePath%>user/updataSelf",
            type:"post",
            dataType:"json",
            success:function (data) {
                var str="<tr>"+
                    "<td>"+data.id+"</td>"+
                    "<td>"+data.userAccount+"</td>"+
                    "<td>"+data.userPassword+"</td>"+
                    "<td>"+data.userName+"</td>"+
                    "<td>"+data.userHobby+"</td>"+
                    "<td>"+data.userPhone+"</td>"+
                    "<td>"+data.userRole+"</td>"+
                    "<td class='td-manage'><button type='button' onclick='openUpdate(this)'><i class='layui-icon'>&#xe642;</button>" +
                    "</tr>";
                $("#tab").html(str);
            },error:function () {
                layer.alert("服务器错误");
            }
        })
    })
	function openUpdate(obj) {
        //获取数据
        var userAccount = $(obj).parent().parent().find('td').eq(1).text();
        var userPassword = $(obj).parent().parent().find('td').eq(2).text();
        var userName = $(obj).parent().parent().find('td').eq(3).text();
        var userHobby = $(obj).parent().parent().find('td').eq(4).text();
        var userPhone = $(obj).parent().parent().find('td').eq(5).text();
        //把数据存入localStorage
        localStorage.setItem("userAccount",userAccount);
        localStorage.setItem("userPassword",userPassword);
        localStorage.setItem("userName",userName);
        localStorage.setItem("userPhone",userPhone);
        localStorage.setItem("userHobby",userHobby);
        //打开修改页面
        x_admin_show('修改用户','./user-edit.jsp',500,500);
    }
</script>
</body>
</html>
